﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ManagementCMS.Tool
{
    public class Rand
    {

        #region 生成随机数字
        public static string Number(int Length)
        {
            return Number(Length, false);
        }

        /// <summary>
        /// 生成随机数字
        /// </summary>
        /// <param name="Length">生成长度</param>
        /// <param name="Sleep">是否要在生成前将当前线程阻止以避免重复</param>
        public static string Number(int Length, bool Sleep)
        {
            //if (Sleep) Thread.Sleep(3);
            StringBuilder str = new StringBuilder();
            Random random = new Random();
            for (int i = 0; i < Length; i++)
            {
                str.Append(random.Next(10).ToString());
            }
            return str.ToString();
        }
        #endregion

    }
}
